import request from '@/config/index';
const deptBaseUrl = '/system/dept';
const postBaseUrl = '/system/post';
const userBaseUrl = '/system/user';

/*========================部门=============================*/ 
// 列表
export const ApiDeptList = () => {
	return request.get({ url: `${deptBaseUrl}/tree` })
}

// 新增
export const ApiDeptAdd = (data) => {
	return request.post({ url: `${deptBaseUrl}/create`, data })
}

// 修改
export const ApiDeptUpdate = (data) => {
	return request.put({ url: `${deptBaseUrl}/update`, data })
}

// 删除
export const ApiDeptDelete = (params) => {
	return request.delete({ url: `${deptBaseUrl}/delete`, params })
}

// 设置部门负责人
export const ApiManager = (id, params) => {
	return request.put({ url: `${deptBaseUrl}/${id}/manager-update`,params })
}

/*========================岗位=============================*/ 
// 列表
export const ApiPostList = () => {
	return request.get({ url: `${postBaseUrl}/list` })
}

// 列表-分页
export const ApiPostPage = (params) => {
	return request.get({ url: `${postBaseUrl}/page`, params })
}

// 新增
export const ApiPostAdd = (data) => {
	return request.post({ url: `${postBaseUrl}/create`, data })
}

// 修改
export const ApiPostUpdate = (data) => {
	return request.put({ url: `${postBaseUrl}/update`, data })
}

// 删除
export const ApiPostDelete = (params) => {
	return request.delete({ url: `${postBaseUrl}/delete`, params })
}


/*========================用户=============================*/ 
// 列表
export const ApiUserPage = (params) => {
	return request.get({ url: `${userBaseUrl}/page`,params })
}

// 所有用户-精简
export const ApiUserList = () => {
	return request.get({ url: `/system/user/simple-list` });
};

// 新增
export const ApiUserAdd = (data) => {
	return request.post({ url: `${userBaseUrl}/create`, data })
}

// 修改
export const ApiUserUpdate = (data) => {
	return request.put({ url: `${userBaseUrl}/update`, data })
}

// 删除
export const ApiUserDelete = (params) => {
	return request.delete({ url: `${userBaseUrl}/delete`, params })
}

// 恢复
export const ApiUserEnable = (id) => {
	return request.put({ url: `${userBaseUrl}/${id}/enable` })
}

// 修改用户密码
export const ApiUserPassword = (params) => {
	return request.put({ url: `${userBaseUrl}/${params.id}/password-update` ,params})
}

// 重置用户密码
export const ApiResetPassword = (params) => {
	return request.put({ url: `${userBaseUrl}/${params.id}/reset/password` ,params})
}

// 离职
export const ApiUserDisable = (params) => {
	return request.put({ url: `${userBaseUrl}/${params.id}/disable` ,params})
}

// 岗位下的用户
export const ApiUserPost = (params) => {
	return request.get({ url: `${userBaseUrl}/list` ,params})
}

// 移出成员
export const ApiUserPostRemove = (params) => {
	return request.delete({ url: `${userBaseUrl}/post/remove`, params})
}

// 添加成员
export const ApiUserPostAdd = (data) => {
	return request.post({ url: `${userBaseUrl}/post/add` ,data})
}

// 调动部门
export const ApiUserChangeDept = (params) => {
	return request.put({ url: `${userBaseUrl}/${params.deptId}/transfer` , params})
}


/*========================文件上传=============================*/ 
// 上传文件
export const ApiUploadMini = (data) => {
    return request.postForm({ url: `/infra/file/upload`, data })
}

/*-------------------------------自定义字段--------------------------------------*/
// 列表
export const ApiFieldsList = (params: any) => {
	return request.get({ url: `/crm/project/biz-config`, params });
};
